﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cecbData;

namespace cecbClasses.Data_Adapters
{
    public class Slider
    {
        public Slider()
        {
            cecbContext = new DSSEntities();
        }

        DSSEntities cecbContext;

        public List<Projects> getProjectDetails()
        {

            IQueryable<Projects> Query =
                  from c in cecbContext.Projects
                  select c;

            List<Projects> SelectedEmpList = Query.ToList();

            return SelectedEmpList;

        }

        public List<Projects> getProjectDetailsByRef(String Id)
        {

            IQueryable<Projects> Query =
                  from c in cecbContext.Projects
                  where c.proj_reference == Id
                  select c;

            List<Projects> SelectedEmpList = Query.ToList();

            return SelectedEmpList;

        }

        public List<Teams> getTeamDetails()
        {

            IQueryable<Teams> Query =
                  from c in cecbContext.Teams

                  select c;

            List<Teams> SelectedEmpList = Query.ToList();

            return SelectedEmpList;

        }

        public List<Teams> getTeamDetailsByRef(String Id)
        {

            IQueryable<Teams> Query =
                  from c in cecbContext.Teams
                  where c.team_reference == Id
                  select c;

            List<Teams> SelectedEmpList = Query.ToList();

            return SelectedEmpList;

        }

        public List<TeamMembers> getTeamMembersByRef(String Id)
        {

            IQueryable<TeamMembers> Query =
                  from c in cecbContext.TeamMembers
                  where c.team_reference == Id
                  select c;

            List<TeamMembers> SelectedEmpList = Query.ToList();
            //==========================

            //===============================

            cecbContext.TeamMembers.Select(s => s.team_reference == "");




            return SelectedEmpList;

        }

        public List<String> getTeamMembersNamesByRef(String refe)
        {

            var _lista = from tm in cecbContext.TeamMembers
                         join t in cecbContext.Members on tm.mem_reference equals t.mem_reference
                         orderby t.mem_id
                         where tm.team_reference == refe
                         select new
                         {
                             t.mem_name

                         };

            List<String> ss = new List<string>();

            foreach (var item in _lista)
            {
                ss.Add(item.mem_name);
            }
            if (ss.Count() == 0)
            {
                ss.Add("No Members Allocated");
            }
            return ss;

        }

        public List<String> getTeamProjectsByTeam(String refe)
        {
            var _lista = from p in cecbContext.Projects
                         //join t in cecbContext.Teams on p. equals t.team_reference
                         //   orderby t.team_id
                         //    where p.M.team_reference == refe

                         select new
                         {
                             p.proj_name

                         };

            //   cecbContext.Projects.Select(s => s.TeamReference );
            List<String> ss = new List<string>();
            foreach (var item in _lista)
            {
                ss.Add(item.proj_name);
            }
            if (ss.Count() == 0)
            {
                ss.Add("No Projects Allocated");
            }
            return ss;
        }

    }
}
